<%@ page language="java" contentType="text/html; charset=UTF-8" %>

<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<c:import url="../../../template/layout.jsp" charEncoding="UTF-8">
  <c:param name="title" value="个人信息" />
  <c:param name="body">

    <div class="content-title">用户信息
      <c:if test="${message!=null}">
        <div class="alert alert-danger" role="alert">${message}</div>
      </c:if>
    </div>
    <button onclick="editUser('<c:url value="/system/person/getUser?id=${user.id}"/>')"
            class="btn btn-primary btn-xs"
            data-toggle="modal" data-target="#editUser">修改个人信息
    </button>
    <button onclick="editPassword('<c:url value="/system/person/getUser?id=${user.id}"/>')"
            class="btn btn-primary btn-xs"
            data-toggle="modal" data-target="#editPassword">修改密码
    </button>
    <%--用户基本信息--%>
    <div align="left" style="width: 600px; margin-right: auto; margin-left: auto;">
      <div class="form-group">
        <label for="username" class="col-sm-2 control-label"><span style="color:red;">*</span>用户名</label>
        <div class="col-sm-10">
          <input type="text" class="form-control" name="username" value="${user.username}" readonly>
        </div>
      </div>value="${user.username}"

      <div class="form-group">
        <label for="mobile" class="col-sm-2 control-label"><span style="color:red;">*</span>手机</label>
        <div class="col-sm-10">
          <input type="text" class="form-control readOnly" name="mobile" value="${user.mobile}" readonly>
        </div>
      </div>
      <div class="form-group">
        <label for="email" class="col-sm-2 control-label"><span style="color:red;">*</span>邮箱</label>
        <div class="col-sm-10">
          <input type="email" class="form-control" name="email" value="${user.email}" readonly>
        </div>
      </div>

      <div class="form-group">
        <label for="realName" class="col-sm-2 control-label"><span style="color:red;">*</span>真实姓名</label>
        <div class="col-sm-10">
          <input type="text" class="form-control" name="realName" value="${user.realName}" readonly>
        </div>
      </div>

      <div class="form-group">
        <label for="role" class="col-sm-2 control-label"><span style="color:red;">*</span>角色</label>
        <div class="col-sm-10">
          <c:if test="${user.viewRoleName !=null}">
            <input type="text" class="form-control" name="viewRoleName" value="${user.viewRoleName}" readonly>
          </c:if>
          <c:if test="${user.viewRoleName ==null}">
            <span>还没有角色</span>
          </c:if>
        </div>
      </div>
    </div>
    <%--经纪人基本信息--%>

    <shiro:hasPermission name="shopAgent:*">
      <c:if test="${user.agent!=null}">
    <div align="left" style="width: 600px; margin-right: auto; margin-left: auto;">
      <div class="form-group">
        <label for="sex" class="col-sm-2 control-label"><span style="color:red;">*</span>性别</label>
        <div class="col-sm-5">
          <span>${user.agent.sex}</span>
        </div>
      </div>
      <div class="form-group">
        <label for="description" class="col-sm-2 control-label"><span style="color:red;">*</span>简介</label>
        <div class="col-sm-10">
          <span>${user.agent.description}</span>
        </div>
      </div>
      <div class="form-group">
        <label for="score" class="col-sm-2 control-label"><span style="color:red;">*</span>积分</label>
        <div class="col-sm-10">
          <span>${user.agent.score}</span>
        </div>
      </div>

      <div class="form-group">
        <label for="state" class="col-sm-2 control-label"><span style="color:red;">*</span>状态</label>
        <div class="col-sm-10">
          <span>${user.agent.state}</span>
        </div>
      </div>
    </div>
      </c:if>
    </shiro:hasPermission>
    <%------------------------------%>
    <script type="text/javascript">

      function editUser(path) {
        $.ajax({
          url: path,
          type: 'get',
          async: true,
          dataType: 'json',
          success: function (user) {
            $('#edit_username').val(user.username);
            $('#edit_mobile').val(user.mobile);
            $('#edit_email').val(user.email);
            $('#edit_realName').val(user.realName);
            $('#edit_id').val(user.id);

          }
        });
      }

      function editPassword(path) {
        $.ajax({
          url: path,
          type: 'get',
          async: true,
          dataType: 'json',
          success: function (user) {
            $('#editPassword_id').val(user.id);

          }
        });
      }


    </script>
    <%--编辑模态框--%>
    <div class="modal fade" id="editUser" tabindex="-1" role="dialog">
      <div class="modal-dialog modal-lg">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal">
              <span aria-hidden="true">&times;</span>
              <span class="sr-only">Close</span>
            </button>
            <h3 class="modal-title">编辑</h3>
          </div>
          <div class="modal-body">
            <form action="/system/person/edit" method="POST">
              <div class="form-group">
                <label class="control-label" for="edit_username">用户名</label>
                <input type="text" class="form-control" id="edit_username" name="username"
                       required>
              </div>
              <div class="form-group">
                <label for="edit_mobile">手机</label>
                <input type="mobile" class="form-control" id="edit_mobile" name="mobile" required/>
              </div>
              <div class="form-group">
                <label class="control-label" for="edit_email">邮箱</label>
                <input type="email" class="form-control" id="edit_email" name="email" required>
              </div>
              <div class="form-group">
                <label for="edit_realName">真实姓名</label>
                <input class="form-control" id="edit_realName" name="realName" required/>
              </div>
              <div class="form-group">
                <input class="form-control" type="hidden" name="id" id="edit_id"/>
              </div>
              <button class="btn btn-primary btn-lg btn-block" type="submit">
                确定
              </button>
            </form>
          </div>
        </div>
      </div>
    </div>
    <%--编辑密码--%>
    <div class="modal fade" id="editPassword" tabindex="-1" role="dialog">
      <div class="modal-dialog modal-lg">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal">
              <span aria-hidden="true">&times;</span>
              <span class="sr-only">Close</span>
            </button>
            <h3 class="modal-title">编辑密码</h3>
          </div>
          <div class="modal-body">
            <form action="/system/person/edit" method="POST">
              <div class="form-group">
                <label class="control-label" for="edit_email">密码</label>
                <input type="password" class="form-control"  name="password" required>
              </div>
              <div class="form-group">
                <label for="edit_realName">确定密码</label>
                <input type="password" class="form-control"  name="rePassword" required/>
              </div>
              <div class="form-group">
                <input class="form-control" type="hidden" name="id" id="editPassword_id"/>
              </div>
              <button class="btn btn-primary btn-lg btn-block" type="submit">
                确定
              </button>
            </form>
          </div>
        </div>
      </div>
    </div>
  </c:param>
</c:import>
